import useBackLogs from '@/hooks/pm/backLogs'
import useOwner from '@/hooks/pm/owner'
import PhoneLayout from '@/layout/index_phone'
import { to_phone_pmBaseInfo } from '@/libs/pageRedirect'
import { defineComponent, onMounted } from 'vue'
import TaskBlock, {TaskContent} from '../taskTodo/components/taskBlock'

export default defineComponent({
  name: 'taskDone',
  setup(props, ctx) {
    const {updateHanderWorkList, handerWorkList} = useBackLogs()
    const {udpateOwnerByPmId} = useOwner()

    onMounted(() => {
      updateHanderWorkList()
    })
    return () => (
      <PhoneLayout
        v-slots={{
          nav: () => (
            <div class='h-36 leading-36 px-16 shadow-card'>
              当前已办：{handerWorkList.value.length || 0}
            </div>
          )
        }}
      >
        <div class='w-full overflow-y-auto pb-36 pt-16'>
          {handerWorkList.value.map(item => (
            <div
              onClick={() => {
                udpateOwnerByPmId({
                  pmId: item.pmId,
                  success(data) {
                    to_phone_pmBaseInfo({
                      defaultPmId: item.pmId,
                      userDDId: data.pmUserDDId
                    })
                  }
                })
              }}
            >
              <TaskBlock title={item.createTime}>
                <TaskContent dataSource={item}></TaskContent>
              </TaskBlock>
            </div>
          ))}
        </div>
      </PhoneLayout>
    )
  }
})
